package top.mable.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.mable.dao.GpPayfeeInfoMapper;
import top.mable.dto.GpPayFeeInfoDTO;
import top.mable.dto.PayfeeInfoDTO;
import top.mable.dto.Result;
import top.mable.service.GpPayfeeInfoService;

import java.util.List;

/**
 * @author wen
 * @date 2022/3/9 17:49
 */
@RestController
@RequestMapping("/payfee")
public class GpPayfeeInfoController {

    @Value("${testValue : testdemo}")
    private String testValue;

    @Autowired
    private GpPayfeeInfoService gpPayfeeInfoService;
    @Autowired
    private GpPayfeeInfoMapper mapper;


    @RequestMapping("/addPayfee")
    public Result addPayfee(@RequestBody GpPayFeeInfoDTO gpPayFeeInfoDTO){
        System.out.println("testValue==" + testValue);
        boolean save = gpPayfeeInfoService.save(gpPayFeeInfoDTO);

        return Result.success(save);
    }

    @RequestMapping("/addPayfeeAES")
    public Result addPayfeeAES(@RequestBody GpPayFeeInfoDTO gpPayFeeInfoDTO){
        gpPayfeeInfoService.addGpPayfeeinfo(gpPayFeeInfoDTO);

        return Result.success();
    }

    @RequestMapping("/getGpPyafeeInfoByParam")
    public Result getGpPyafeeInfoByParam(@RequestBody GpPayFeeInfoDTO gpPayFeeInfoDTO){
        GpPayFeeInfoDTO gpPyafeeInfoById = mapper.getGpPyafeeInfoByParam(gpPayFeeInfoDTO);
        return Result.success(gpPyafeeInfoById);
    }

    @RequestMapping("/getGpPyafeeInfoByPayfeeInfo")
    public Result getGpPyafeeInfoByPayfeeInfo(@RequestBody PayfeeInfoDTO gpPayFeeInfoDTO){
        GpPayFeeInfoDTO gpPyafeeInfoById = mapper.getGpPyafeeInfoByPayfeeInfoDTO(gpPayFeeInfoDTO);
        return Result.success(gpPyafeeInfoById);
    }

    @RequestMapping("/getAllPayfee")
    public Result getAllPayfee(){
        List<GpPayFeeInfoDTO> list = gpPayfeeInfoService.list();
        return Result.success(list);
    }



}
